package com.tedu.lingmaagent.controller;

import com.tedu.lingmaagent.assistant.Assistant;
import com.tedu.lingmaagent.domain.FormMessage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@Tag(name = "灵码挂号")
@RequestMapping("/lingma")
@RestController
public class LingMaController {

    @Autowired
    private Assistant assistant;

    @Operation(summary = "聊天")
    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody FormMessage formMessage) {
        return assistant.chat(formMessage.getMemoryId(), formMessage.getMessage());
    }
}